Carga de los datos de los jegadores de FIFA
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import plotly.express as px
import numpy
df = pd.read_csv('fifa_datos.csv')
df
| Columna | ID | Name | Age | Photo | Nationality | Flag | Overall | Potential | Club | ... | Composure | Marking | StandingTackle | SlidingTackle | GKDiving | GKHandling | GKKicking | GKPositioning | GKReflexes | Release Clause | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 158023 | L. Messi | 31 | https://cdn.sofifa.org/players/4/19/158023.png | Argentina | https://cdn.sofifa.org/flags/52.png | 94 | 94 | FC Barcelona | ... | 96.0 | 33.0 | 28.0 | 26.0 | 6.0 | 11.0 | 15.0 | 14.0 | 8.0 | €226.5M |
| 1 | 1 | 20801 | Cristiano Ronaldo | 33 | https://cdn.sofifa.org/players/4/19/20801.png | Portugal | https://cdn.sofifa.org/flags/38.png | 94 | 94 | Juventus | ... | 95.0 | 28.0 | 31.0 | 23.0 | 7.0 | 11.0 | 15.0 | 14.0 | 11.0 | €127.1M |
| 2 | 2 | 190871 | Neymar Jr | 26 | https://cdn.sofifa.org/players/4/19/190871.png | Brazil | https://cdn.sofifa.org/flags/54.png | 92 | 93 | Paris Saint-Germain | ... | 94.0 | 27.0 | 24.0 | 33.0 | 9.0 | 9.0 | 15.0 | 15.0 | 11.0 | €228.1M |
| 3 | 3 | 193080 | De Gea | 27 | https://cdn.sofifa.org/players/4/19/193080.png | Spain | https://cdn.sofifa.org/flags/45.png | 91 | 93 | Manchester United | ... | 68.0 | 15.0 | 21.0 | 13.0 | 90.0 | 85.0 | 87.0 | 88.0 | 94.0 | €138.6M |
| 4 | 4 | 192985 | K. De Bruyne | 27 | https://cdn.sofifa.org/players/4/19/192985.png | Belgium | https://cdn.sofifa.org/flags/7.png | 91 | 92 | Manchester City | ... | 88.0 | 68.0 | 58.0 | 51.0 | 15.0 | 13.0 | 5.0 | 10.0 | 13.0 | €196.4M |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 18202 | 18202 | 238813 | J. Lundstram | 19 | https://cdn.sofifa.org/players/4/19/238813.png | England | https://cdn.sofifa.org/flags/14.png | 47 | 65 | Crewe Alexandra | ... | 45.0 | 40.0 | 48.0 | 47.0 | 10.0 | 13.0 | 7.0 | 8.0 | 9.0 | €143K |
| 18203 | 18203 | 243165 | N. Christoffersson | 19 | https://cdn.sofifa.org/players/4/19/243165.png | Sweden | https://cdn.sofifa.org/flags/46.png | 47 | 63 | Trelleborgs FF | ... | 42.0 | 22.0 | 15.0 | 19.0 | 10.0 | 9.0 | 9.0 | 5.0 | 12.0 | €113K |
| 18204 | 18204 | 241638 | B. Worman | 16 | https://cdn.sofifa.org/players/4/19/241638.png | England | https://cdn.sofifa.org/flags/14.png | 47 | 67 | Cambridge United | ... | 41.0 | 32.0 | 13.0 | 11.0 | 6.0 | 5.0 | 10.0 | 6.0 | 13.0 | €165K |
| 18205 | 18205 | 246268 | D. Walker-Rice | 17 | https://cdn.sofifa.org/players/4/19/246268.png | England | https://cdn.sofifa.org/flags/14.png | 47 | 66 | Tranmere Rovers | ... | 46.0 | 20.0 | 25.0 | 27.0 | 14.0 | 6.0 | 14.0 | 8.0 | 9.0 | €143K |
| 18206 | 18206 | 246269 | G. Nugent | 16 | https://cdn.sofifa.org/players/4/19/246269.png | England | https://cdn.sofifa.org/flags/14.png | 46 | 66 | Tranmere Rovers | ... | 43.0 | 40.0 | 43.0 | 50.0 | 10.0 | 15.0 | 9.0 | 12.0 | 9.0 | €165K |
18207 rows × 89 columns
p1 = 0
p2 = 0
p3 = 0
p4 = 0
separador = "lbs"
for x in df['Weight']:
separado = str(x).split(separador)
x1 = float(separado[0])
if x1 < 125:
p1+=1
elif x1 < 150:
p2+=1
elif x1 < 175:
p3+=1
else:
p4+=1
pesos = [p1, p2, p3, p4]
pesos
[41, 2290, 10876, 5000]
random_x = [41, 2290, 10876, 5000]
names = ['<125 lbs', '125 - 150 lbs', '150 - 175 lbs', '>175 lbs']
fig = px.pie(values=random_x, names=names)
fig.show()
x1; x2=0; x3=0; x4=0; x5=0; x6 = 0
for x in df['Overall']:
if x < 50:
x1+=1
elif x < 60:
x2 +=1
elif x < 70:
x3+=1
elif x < 80:
x4+=1
elif x < 90:
x5+=1
else:
x6+=1
overall = [x1, x2, x3, x4, x5, x6]
print(overall)
[265.0, 2815, 9665, 5083, 541, 14]
plt.figure(figsize=(10,12))
plt.bar(['40-50', '50-60', '60-70', '70-80', '80-90', '90-100'], overall, color='lightsteelblue', width=0.9)
plt.yticks(np.arange(0, 10001, 500))
plt.grid(linestyle='--', linewidth=0.5)
plt.show()
Investigar alguna herramienta o software que permita generar reportes con Python